const openWebpackBundleAnalyze = true;

const BundleAnalyzerPlugin =
  require("webpack-bundle-analyzer").BundleAnalyzerPlugin;

module.exports = (config) => {
  // 关闭webpack展示性能提示
  config.performance.hints(false);

  // 开启性能监控
  if (openWebpackBundleAnalyze) {
    // vue-cli-service build --modern
    if (process.env.VUE_CLI_MODERN_MODE) {
      config.plugin("webpack-bundle-analyzer").use(BundleAnalyzerPlugin, [
        {
          analyzerPort: 10010,
          generateStatsFile: false
        }
      ]);
    } else {
      config.plugin("webpack-bundle-analyzer").use(BundleAnalyzerPlugin, [
        {
          analyzerPort: 10011,
          generateStatsFile: false
        }
      ]);
    }
  }
};
